
import {focusUser} from "../../api/um";
const {globalData} = getApp();
const {colorOption, config, userInfo} = globalData;

Component({

  /**
   * 组件的属性列表
   */
  properties: {
    userInfo:{
      type: Object,
      value: {}
    },
    showFocus:{
      type: Boolean,
      value: false
    },
    showMatchDegree:{
      type: Boolean,
      value: false
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    config,
    colorOption,
    myInfo:userInfo,
    hobbyList:[],
    attrDataMap:{}
  },

  observers: {
    userInfo: function () {
      let {userInfo} = this.properties;
      let {hobbyList} = this.data;
      let {attrDataMap} = userInfo;

      if (userInfo.attrDataMap.XQAH_str) {
        hobbyList = userInfo.attrDataMap.XQAH_str.split("丨").splice(0,4);
      }
      this.setData({
        hobbyList: hobbyList,
        attrDataMap:attrDataMap,
      })
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 跳转交友名片页面
    goDetail(e) {
      if(globalData.userInfo.authStatus == 9){
        wx.navigateTo({
          url: `/pageA/pages/friends-card/index?id=${this.data.userInfo.id}`,
        });
      }else{
        this.triggerEvent("handleAuth",e);
      }
    },
    // 关注按钮
    handleFocus(e) {
      if(!this.data.userInfo.isFocus){
        wx.showLoading({title: '操作中',})
        focusUser(this.data.userInfo.id, () => {
          this.triggerEvent("handleFocus",e);
          setTimeout(()=>wx.hideLoading(), 200);
        });
      }
    },
  }
})